function q=is_in_boundary(pos,bnd)
% is_in_boundary: Test whether a position is in the specified boundary object.
%
% SYNTAX:
%   ret = is_in_boundary(pos,bnd)
%   Return 1 if specified position pos lies in the boundary bnd or 0 if otherwise.
%   Boundary object obs should be created with function NEWBOUNDARY.

%   Author: Hongbin Ma
%   Last updated: 2009-6-2 with MATLAB 6.5
%   Problems or suggestions? Email me: mathmhb[at]163.com

q=-1;
if isempty(pos)|isempty(bnd),
    return;
end;
in=inpoly(pos-bnd.pos,bnd.nodes(bnd.convhull,:));
q=in;
